package com.atgui.springcloud.controller;

import com.atgui.springcloud.feign.PaymentFeignService;
import com.atguigu.springcloud.entities.Payment;
import com.atguigu.springcloud.result.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yanglin
 * @create 2023-11-11 11:19 星期六
 * description:
 */
@RestController
public class OrderController {
    
    @Autowired
    private PaymentFeignService paymentFeignService;
    
    @GetMapping("/consumer/payment/get/{id}")
    public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id){
        CommonResult<Payment> paymentById = paymentFeignService.getPaymentById(id);
        return paymentById;
    }

    @GetMapping("/consumer/payment/feign/timeout")
    public String paymentFeignTimeOut(){
        //openFeign底层是Ribbon，客户端一般默认等待1秒钟
        String s = paymentFeignService.paymentFeignTimeOut();
        return s;
    }
}
